{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="user_name" class="layui-input search" name="user_name" value="" placeholder="姓名|企业名称|产品名称"/>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px;">
                            <select name="user_type" class="layui-input">
                                <option value="">不限用户类型</option>
                                <option value="1">医生</option>
                                <option value="2">代表</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="sae_submit" class="layui-input">
                                <option value="">不限上报状态</option>
                                <option value="1">未上报</option>
                                <option value="2">已上报</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="sae_answer" class="layui-input">
                                <option value="">不限解决状态</option>
                                <option value="1">未解决</option>
                                <option value="2">已解决</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="sae_zhuan" class="layui-input">
                                <option value="">不限转让与否</option>
                                <option value="1">未转让同事</option>
                                <option value="2">已转让同事</option>
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text"  name="start" style="margin-top: 5px" onclick="wk.lay_date(this);"  class="layui-input search" placeholder="提交时间-起" />
                        </div>
                        <div class="layui-input-inline">
                            <input type="text"  name="end" style="margin-top: 5px" onclick="wk.lay_date(this);"  class="layui-input search" placeholder="提交时间-止" />
                        </div>
                        <div class="layui-input-inline">
                            <input type="text"  name="loginstart" style="margin-top: 5px" onclick="wk.lay_date(this);"  class="layui-input search" placeholder="上报时间-起" />
                        </div>
                        <div class="layui-input-inline">
                            <input type="text"  name="loginend" style="margin-top: 5px" onclick="wk.lay_date(this);"  class="layui-input search" placeholder="上报时间-止" />
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 导出sae数据 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 导出选中数据</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>
                        </ul>
                    </div>
                </div>
                <!--搜索框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--修改状态模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.user_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>
                    <!--状态显示模板-->
                    <!--图片模板-->
                    <!--操作模板-->
                    <script type="text/html" id="user_type">
                    {{# if(d.user_type == 1){ }}
                    医生
                    {{# } }}
                    {{# if(d.user_type == 2){ }}
                    代表
                    {{# } }}
                    </script>
                    <script type="text/html" id="sae_submit">
                    {{# if(d.sae_submit == 1){ }}
                    未上报
                    {{# } }}
                    {{# if(d.sae_submit == 2){ }}
                    已上报(上报时间：{{d.sae_submit_time}})
                    {{# } }}
                    </script>
                    <script type="text/html" id="sae_answer">
                    {{# if(d.sae_answer == 1){ }}
                    未解决
                    {{# } }}
                    {{# if(d.sae_answer == 2){ }}
                    已解决
                    {{# } }}
                    </script>
                    <script type="text/html" id="sae_zhuan">
                    {{# if(d.sae_zhuan == 1){ }}
                    未转让
                    {{# } }}
                    {{# if(d.sae_zhuan == 2){ }}
                    已转让
                    {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('查看详情','{:url('saeInfo')}?sae_id={{d.sae_id}}')" class="btn btn-primary btn-xs m-r-xs" title="查看详情">查看详情</a>
                        <a href="javascript:;" onclick="wk.layer_show('查看回复', '{:url('seeReplys')}?sae_id={{d.sae_id}}')" class="btn btn-primary btn-xs m-r-xs" title="查看回复">查看回复</a>
                        {{# if(d.sae_zhuan == 2){ }}
                        <a href="javascript:;" onclick="wk.layer_show('转让信息', '{:url('zhuanUsers')}?uids={{d.sae_zhuan_ids}}')" class="btn btn-primary btn-xs m-r-xs" title="转让信息">转让信息</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("sae/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , where: {'jump_uid':"{$jump_uid}"}
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left'},
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 'sae_id', width: 80, title: '报告ID', align: 'center'}
                , {field: 'user_username', width: '', title: '用户姓名', align: 'center'}
                , {field: 'user_image', width: '90', title: '用户头像', align: 'center',templet: '#imgTpl'}
                , {field: 'user_phone', width: '', title: '用户电话', align: 'center'}
                , {field: 'user_type', width: '90', title: '用户类型', align: 'center',templet: '#user_type'}
                , {field: 'sae_time', width: '', title: '提交时间', align: 'center'}
                , {field: 'sae_submit', width: '90', title: '上报状态', align: 'center',templet: '#sae_submit'}
                , {field: 'cp_name', width: '90', title: '产品名称', align: 'center'}
                , {field: 'c_name', width: '90', title: '关联企业', align: 'center'}
                , {field: 'c_charge_name', width: '110', title: '企业负责人', align: 'center'}
                , {field: 'sae_answer', width: '90', title: '解决状态', align: 'center',templet: '#sae_answer'}
                , {field: 'sae_zhuan', width: '', title: '是否转让同事', align: 'center',templet: '#sae_zhuan'}
                , {fixed: 'right', width:230, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original'
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true ? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("comStatus")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAll('all',$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['sae_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>